<!DOCTYPE html>
<html lang="en">
<head>
<title>教师信息管理系统</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="../css/bootstrap.min.css" />
  <link rel="stylesheet" href="../css/bootstrap-responsive.min.css" />
  <link rel="stylesheet" href="../css/colorpicker.css" />
  <link rel="stylesheet" href="../css/datepicker.css" />
  <link rel="stylesheet" href="../css/uniform.css" />
  <link rel="stylesheet" href="../css/select2.css" />
  <link rel="stylesheet" href="../css/matrix-style2.css" />
  <link rel="stylesheet" href="../css/matrix-media.css" />
  <link rel="stylesheet" href="../css/bootstrap-wysihtml5.css" />
  <link href="../font-awesome/css/font-awesome.css" rel="stylesheet" />
  <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
</head>
<body>

<div id="content">
  <div id="content-header">
    <h1>专业教师基本情况</h1>
  </div>

  <div class="container-fluid">
    <div>
      <form class="form-horizontal" style="display: inline-block; ">
        <div class="control-group" style="display: inline-block;">
          <span class="control-label">姓名：</span>
          <div class="controls">
            <input id="name" type="text"  />
          </div>
        </div>
        <div class="control-group" style="display: inline-block; ">
          <span class="control-label">主讲课程：</span>
          <div class="controls">
            <input id="courseName" type="text"  />
          </div>
        </div>
        <div class="control-group" style="display: inline-block; ">
          <span class="control-label">任课时期：</span>
          <div class="controls">
            <select id="termTime">
              <option value=""></option>
              <option value="2015-2016第二学期">2015-2016第二学期</option>
              <option value="2016-2017第一学期">2016-2017第一学期</option>
              <option value="2016-2017第二学期">2016-2017第二学期</option>
              <option value="2017-2018第一学期">2017-2018第一学期</option>
              <option value="2017-2018第二学期">2017-2018第二学期</option>
              <option value="2018-2019第一学期">2018-2019第一学期</option>
              <option value="2018-2019第二学期">2018-2019第二学期</option>
              <option value="2019-2020第一学期">2019-2020第一学期</option>
            </select>
          </div>
        </div>
      </form>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <button id="su" class="btn btn-warning" style="display: inline-block; ">搜索</button>
    </div>
    <hr>
    <div class="row-fluid">
      <div class="span12">
        <form action="/teacherInfo/leadOutAll" method="post" style="display: inline-block;">
          <input id="cuId2" name="cuId" type="text" style="display: none" >
          <input type="submit" class="btn btn-info btn-large" style="border-radius: 5px"; value="全部导出";>
        </form>
        <div class="widget-box">
          <div class="widget-title"> <span class="icon">
           </span>
            <h5>专业教师基本情况</h5>
          </div>
          <div class="widget-content nopadding">
            <table id="t1" class="table table-bordered table-striped" frame="box">
              <thead>
              <tr >
                <th>编号</th>
                <th>教师姓名</th>
                <th>主讲课程</th>
                <th>任课时期</th>
                <th>本人承担实际学时</th>
                <th>操作</th>
              </tr>
              </thead>
              <tbody id="tbody">


              </tbody>
            </table>
            <div class="pagination" style="margin-left: 70%">
              <ul>
                <li><a href="#" id="first">第一页</a></li>
                <li><a href="#" id="previous">上一页</a></li>
                <li><a href="#" pageNum="1">1</a> </li>
                <li><a href="#" pageNum="2">2</a></li>
                <li><a href="#" pageNum="3">3</a></li>
                <li><a href="#" pageNum="4">4</a></li>
                <li><a href="#" pageNum="5">5</a></li>
                <li><a href="#" id="next">下一页</a></li>
                <li><a href="#" id="last">最后一页</a></li>

                <li><a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <span id="span2"></span>&nbsp;&nbsp;共<span id="span1"></span>条记录
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="http://www.jq22.com/jquery/jquery-1.7.1.js"></script>
<script src="../js/jquery.ui.custom.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootstrap-colorpicker.js"></script>
<script src="../js/bootstrap-datepicker.js"></script>

<script src="../js/masked.js"></script>
<script src="../js/jquery.uniform.js"></script>
<script src="../js/select2.min.js"></script>
<script src="../js/matrix.js"></script>
<script src="../js/matrix.form_common.js"></script>
<script src="../js/wysihtml5-0.3.0.js"></script>
<script src="../js/jquery.peity.min.js"></script>
<script src="../js/bootstrap-wysihtml5.js"></script>
<script type="text/javascript" src="../js/jquery.cookie.js"></script>
<script src="../js/tool.js"></script>

<script type="text/javascript">
  $(function () {
    queryPage(1);

    $("#su").click(function () {
      queryPage(1);
    })
    $(".pagination a").bind("click",function(){
      var num = $(this).attr("pageNum");
      if (num<=lastPage){
        queryPage(num);
      }
      if ($(".pagination a").attr("pageNum")==num){
        $(this).parent("li").attr("class","active");
      }
    });
    $("#remove").live("click",function() {
      var r = confirm("\t确定删除？")
      if (r == true) {
        var eid = $(this).attr("eid");
        var cid = $(this).attr("cid");
        $.ajax({
          url:"../teacherInfo/byCuId/"+ eid+"/"+cid,
          type:"delete",
          data:{},
          dataType:"json",
          success:function (result) {
            if (result.resp_code == "0") {
              alert(result.resp_msg);
              window.location.href = "teachings.html";
            }else {
              $("#span1").text(result.resp_msg);
            }
          }
        })
      }
    })
  })
  //表格填充函数
  function queryPage(pageNum){
    var name=$("#name").val();
    var courseName=$("#courseName").val();
    var termTime=$("#termTime").val();
    //当前页码
    pageNum= pageNum==undefined?1:pageNum;
    //页码的有效性判断
    $.get("/teacherInfo/findAllUsers",{name:name,courseName:courseName,termTime:termTime,page:pageNum,limit:5},function(result){
      console.log(result);
      //填充数据到tbody
      $("#tbody").empty();//清除之前的内容
      $(result.data).each(function(index,teacherInfo){
        $("#tbody").append(
                " <tr>"+
                "<td>"+(index+1)+"</td>"+
                "<td>"+teacherInfo.name+"</td>"+
                "<td >"+teacherInfo.courseName+"</td>"+
                "<td >"+teacherInfo.termTime+"</td>"+
                "<td>"+teacherInfo.persion+"</td>"+
                "<td>"+
                "<a href='#' id='remove' class='icon-trash' eid="+teacherInfo.cuId+" cid="+teacherInfo.courseNum+">删除</a></td>"+
                "</tr>"
        );
      })
      //给按钮添加对应的数值
      var num = pageNum;
      var count=result.count;
      lastPage=(count/5)%1===0?(count/5):parseInt(count/5)+1;
      $("a#first").attr("pageNum",1);
      $("a#previous").attr("pageNum",num-1<1?1:num-1);
      $("a#next").attr("pageNum",num+1>lastPage?lastPage:num+1);
      $("a#last").attr("pageNum",lastPage);
      $("span#span1").text(count);
      $("span#span2").text("第"+num+"页/共"+lastPage+"页");

      $("#pageNum").val(num);

    },"json");

  }
</script>
</body>
</html>
